package com.shujia.alink;

import com.alibaba.alink.common.MLEnvironmentFactory;
import com.alibaba.alink.pipeline.PipelineModel;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.java.BatchTableEnvironment;
import org.apache.flink.types.Row;

public class Test1 {
    public static void main(String[] args) throws Exception {
        ExecutionEnvironment env = MLEnvironmentFactory.getDefault().getExecutionEnvironment();

        DataSource<String> dataSource = env.fromElements("辛苦你俩了半夜回来第二天点就赶回去");

        BatchTableEnvironment tableEnv = BatchTableEnvironment.create(env);

        Table text = tableEnv.fromDataSet(dataSource, "text");

        PipelineModel model = PipelineModel.load("flink_alink/data/model");

        Table transform = model.transform(text);
        transform.printSchema();
        tableEnv.toDataSet(transform, Row.class).print();


    }
}
